package mis.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import mis.module.base.dao.CustomerDao;
import mis.module.base.model.Customer;
import mis.module.base.service.CustomerService;
/**
 * 客户业务实现类
 * @author DCJ
 *
 */
@Service
public class CustomerServiceImpl implements CustomerService {
	@Autowired
	private CustomerDao customerDao;

	@Override
	public void saveCustomer(Customer customer) {
		customerDao.save(customer);
		
	}
	@Override
	public void updateCustomer(Customer customer) {
		customerDao.update(customer);
		
	}
	@Override
	public void deleteCustomer(int id) {
		Customer customer = customerDao.get(id);
		customerDao.delete(customer);
	}

	@Override
	public List<Customer> findAllCustomer(int page, int rows, String sort, String order) {
		return customerDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return customerDao.countAll();
	}
	@Override
	public boolean isExist(String customerNo) {
		boolean flag = false;
		String hql="from Customer as c where c.CustomerNo="+customerNo;
		if (customerDao.find(hql).size()>0){
			flag = true;
		}
		return flag;
	}
}
